# Maintainer: David Runge <dave@sleepmap.de>
pkgname=ambdec
pkgver=0.7.1
pkgrel=2
pkgdesc="An Ambisonic decoder for first and second order"
arch=('loong64' 'x86_64')
url="https://kokkinizita.linuxaudio.org/linuxaudio/downloads/index.html"
license=('GPL2')
groups=('pro-audio')
depends=('clxclient' 'clthreads' 'jack')
makedepends=('gendesk')
source=("https://kokkinizita.linuxaudio.org/linuxaudio/downloads/${pkgname}-${pkgver}.tar.bz2")
sha512sums=('26f945e07a5e3e3a2000f00eede2499fd6a6ba82587a84d1bbd344ac3c6c8b86d74773491c9366d79b3697c926950308b5f8593ad14316eced7155d48c1ace0e')

prepare() {
  cd "$pkgname-$pkgver"
  # strip march=native
  sed -e '/native/d' \
      -i source/Makefile
  # XDG desktop file
  gendesk -n \
          --pkgname "${pkgname}" \
          --name "${pkgname}" \
          --pkgdesc "${pkgdesc}" \
          --genericname "Ambisonics Audio Renderer" \
          --categories "AudioVideo;Audio"
}

build() {
  cd "$pkgname-$pkgver/source"
  make PREFIX=/usr
}

package() {
  cd "$pkgname-$pkgver/source"
  make PREFIX=/usr DESTDIR="$pkgdir/" install
  install -vDm 644 ../{AUTHORS,README} -t "${pkgdir}/usr/share/doc/${pkgname}/"
  install -vDm 644 ../presets/*.ambdec \
    -t "${pkgdir}/usr/share/${pkgname}/presets/"
  install -vDm 644 ../share/*.png \
    -t "${pkgdir}/usr/share/${pkgname}/"
  install -vDm 644 "../${pkgname}.desktop" \
    -t "${pkgdir}/usr/share/applications/"
}
